﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.ComponentModel;

namespace Kokomo.Mirror.PeFormat
{
	[Description("COR 2.0 Stream Header")]
	public class Cor20StreamHdr : PeHeaderStruct
	{
		public override string ToString()
		{
			return string.Format("{0} @ 0x{1:X8}, Length=0x{2:X8}", this.Name, this.Offset, this.Size);
		}

		[TypeConverter(typeof(HexConverter))]
		public uint Offset { get; private set; }

		[TypeConverter(typeof(HexConverter))]
		public uint Size { get; private set; }

		[SerializedArray(ArrayLengthEncoding.ZeroTerminated)]
		public string Name { get; private set; }

		[Browsable(false)]
		public int NamePaddingLength { get { return (4 - ((this.Name.Length + 1) % 4)) % 4; } }

		[SerializedArray(ArrayLengthEncoding.ElementPrefixField, "NamePaddingLength")]
		[Browsable(false)]
		public byte[] NamePadding { get; private set; }
	}
}
